#!/usr/bin/python3

# generate LOGO lines for gowin_dpb_menu.v

# 72 columns, 14 rows
LOGO = ["000011110000110011111111001111001111111110000000000000000000000000000000",
        "000011110000110011111111011111101111111110000000000000000000000000000000",
        "000011111000110011100000011100100001110000000000000000000000000000000000",
        "000011111000110011100000011100000001110000011111000111111100001111110000",
        "000011011100110011111110001110000001110000110011100111001110011100111000",
        "000011001110110011111110000111000001110000000011100110001110011000111000",
        "000011001111110011000000000011100001110000111111100110001110111000111000",
        "000011000111110011000000110011100001110001111111100110001110111000111000",
        "000011000011110011111110111111100001100001110011100110001110011001111000",
        "000011000011110011111110011111000001100000111111100110001110001111111000",
        "000000000000000000000000000000000000000000000000000000000000000000111000",
        "000000000000000000000000000000000000000000000000000000000000011001110000",
        "000000000000000000000000000000000000000000000000000000000000011111100000",
        "000000000000000000000000000000000000000000000000000000000000000000000000",
        ]

# gowin_dpb_menu.v's logo format is 9 bytes per row, 14 rows, in total 126 bytes

r = []

for i in range(126):
    j = i % 9
    s = LOGO[i // 9][j*8 : j*8+8]
    b = 0
    for k in range(8):
        if s[k] == '1':
            b += 1 << k
    # print("{} -> {:02X}".format(s, b))
    r.append(b)

assert(len(r) == 126)

r.append(0)
r.append(0)

for i in range(4):
    off = i * 32
    print("defparam dpb_inst_0.INIT_RAM_{:02X} = 256'h".format(0x1C+i), end='')
    for j in range(31, -1, -1):     # 31, 30, ...
        print("{:02X}".format(r[off+j]), end='')
    print()

